package org.correct.crawler;

/**
 * DomainFilter will filter out all the domains that are not specified.
 * 
 * @author Li Yujia
 *
 */
public class AllowDomainFilter implements Filter {
	private String[] domain;
	
	public AllowDomainFilter(String domain) {
		this.domain = new String[1];
		this.domain[0] = domain;
	}
	
	public AllowDomainFilter(String[] domainList) {
		domain = new String[domainList.length];
		
		for(int i = 0; i < domain.length; i++)
			domain[i] = domainList[i];
	}
	
	@Override
	public boolean filter(String url) {
		for(int i = 0; i < domain.length; i++) {
			if(url.contains(domain[i]))
				return false;
		}
		return true;
	}
}
